package top.goldenyear.porpoise.infra.job.controller.admin;

import lombok.extern.slf4j.Slf4j;
import org.noear.solon.annotation.*;
import top.goldenyear.porpoise.common.core.model.Ret;
import top.goldenyear.porpoise.framework.web.core.controller.BaseController;
import top.goldenyear.porpoise.framework.web.core.model.query.QPage;
import top.goldenyear.porpoise.infra.job.model.JobLog;
import top.goldenyear.porpoise.infra.job.service.JobLogService;

import java.util.List;


/**
 * 定时任务日志表 Controller 控制层
 *
 * @author airhead
 * @since 2024-12-21
 */
@Component(tag = "admin")
@Mapping("/job/jobLog")
@Slf4j
public class JobLogAdminController extends BaseController {
  @Inject private JobLogService service;

  @Post
  @Mapping("create")
  public Ret create(@Body JobLog jobLog) {
    return Ret.okWithData(service.createJobLog(jobLog));
  }

  @Post
  @Put
  @Mapping("update")
  public Ret update(@Body JobLog jobLog) {
    return Ret.okWithData(service.updateJobLog(jobLog));
  }

  @Get
  @Mapping("get")
  public Ret get(@Param Long id) {
    return Ret.okWithData(service.getJobLog(id));
  }

  @Post
  @Delete
  @Mapping("delete")
  public Ret delete(@Param Long id) {
    return Ret.okWithData(service.deleteJobLog(id));
  }

  @Post
  @Delete
  @Mapping("batchDel")
  public Ret batchDel(@Param List<Long> ids) {
    return Ret.okWithData(service.batchDelJobLog(ids));
  }

  @Get
  @Mapping("paginate")
  public Ret paginate(QPage qPage) {
    JobLog jobLog = getBean(JobLog.class);
    return Ret.okWithData(service.paginateJobLog(qPage, jobLog));
  }

  @Get
  @Mapping("list")
  public Ret list() {
    JobLog jobLog = getBean(JobLog.class);
    return Ret.okWithData(service.listJobLog(jobLog));
  }

//  @Get
//  @Mapping("simpleList")
//  public Ret simpleList() {
//    JobLog jobLog = getBean(JobLog.class);
//    return Ret.okWithData(service.simpleListJobLog(jobLog));
//  }

//  @Get
//  @Mapping("options")
//  public Ret options() {
//    JobLog jobLog = getBean(JobLog.class);
//
//    return Ret.okWithData(service.optionsJobLog(dictCode));
//  }
}